<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/27/027
 * Time: 15:41
 */

namespace App\Http\Controllers\Product;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Session;
use Config;
use App\Http\Service\Product\ProductService;

use Illuminate\Support\Facades\Redis;

class IndexController extends Controller
{

    public function index(){
        return view('Index.set_meal_price');
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 套餐列表
     */
    public function getProductList(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new ProductService();
        $data = $agent->getProductList($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 添加套餐
     */
    public function addProduct(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new ProductService();
        $data = $agent->doProductAdd($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 修改套餐
     */
    public function updateProduct(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new ProductService();
        $data = $agent->doProductUpdate($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 修改套餐
     */
    public function deleteProduct(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new ProductService();
        $data = $agent->doProductDelete($where);
        return $data;
    }
}